<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
$gType = chkGametype($gametype);
switch ($gType)
{
    case 0 :
        $ui = new UI();
        break;
    default :
        include_once( "class_3d/CheckMode_3d.php" );
        $chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
        $chk->checkShow3dPage();
        unset($chk);
        $ui = new UI_3D();
        $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>" . "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>";
        $ui->set("jslink", $jslink);
        $ui->header();
}
$tpl = new Template2();
$reat0_open = $conf->get("reat0_open");
if (isset($_POST['id']))
{
    $id = getvar("id");
    if ($id == "")
    {
        $ui->showErrorPage("请输入会员帐号！");
        exit();
    }
    $rs = getdb("select * from k_user where account='" . $id . "' and acl<5");
    if ($rs->eof)
    {
        $ui->showErrorPage("错误的会员帐号！");
        exit();
    }
    echo "<script> \r\n        function password_link(gametype,id){\r\n          var oObj = document.getElementById('password_link');\r\n          var sUrl = 'op.php?op=admin&fp=logindata&id=' + id + '&gametype=' + gametype;\r\n          oObj.innerHTML = \"<div class='td0 bgImg_\" + gametype + \"' align=right><input type=button value=&nbsp;X&nbsp; onclick=javascript:close_password_link(); class=c4></div><iframe name=iframe_all src=\" + sUrl + \" width=340 height=400></iframe><br />\"; \r\n          oObj.className = 'logindata';\r\n        }\r\n        function close_password_link(){\r\n          var oObj = document.getElementById('password_link');\r\n          oObj.innerHTML = '';\r\n          oObj.className= 'noneRateRecord';\r\n        }\r\n        </script>";
    echo "<style>\r\n        .logindata{\r\n          text-align:center;\r\n          z-index: 1;\r\n          position: absolute;\r\n          border: 2px dashed #FFB85D;\r\n          background-color: #FFFFFF;\r\n          padding:0;\r\n          margin: 20px 0px 0px 800px;\r\n          top:10px;\r\n          left:10px;\r\n        }\r\n        </style>";
    echo " &nbsp; <a href=\"javascript:history.back()\">[回上一页]</a>";
    echo "<table border='1' cellpadding='3' cellspacing='0' width='800'>";
    echo "<tr class=td0 align=center><td width=\"50\">管理层<td width=\"30\">ID<td width=\"50\">帐号<td width=\"50\">名称";
    echo "<div id=\"password_link\"></div>";
    echo "<td nowrap>信用额度";
    //if ($g_init_mode_6h && $reat0_open)
    //{
    //    echo "<td nowrap>特码减倍";
    //}
    //if ($g_init_mode_3d)
   // {
    //    echo "<td nowrap class=c3>福体彩信用额度<td nowrap class=c4>时时信用额度";
   // }
    echo "<td nowrap>最後登入日<td nowrap>最後登入IP<td nowrap>检视登入纪录";
    $acl = $rs->f['acl'];
    if ($acl < 3 && 0 < $acl)
    {
        $showPerFlag = true;
    }
    else
    {
        $showPerFlag = false;
    }
    if ($acl < 0 && 0 - 6 < $acl)
    {
        $tempUPAcl = get_user($rs->f['prev_id'], $gametype);
        echo "<tr class=td2><td nowrap class=td5 align=center>" . $aclname[$tempUPAcl['acl']] . "子帐号<br />归属:" . $tempUPAcl['account'] . "<td nowrap>" . $rs->f['id'] . "<td nowrap>" . $rs->f['account'] . "<td nowrap>" . $rs->f['name'];
        echo "<td nowrap align=right> -- ";
        //if ($g_init_mode_6h && $reat0_open)
        //{
        //    echo "<td nowrap align=right> -- ";
        //}
        //if ($g_init_mode_3d)
        //{
        //    echo "<td nowrap align=right> -- <td nowrap align=right> -- ";
        //}
        echo "<td nowrap>" . ( date("Y-m-d", $rs->f['lastlogdt']) ) . "<td nowrap>" . $rs->f['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $rs->f['id'] . ");>";
    }
    switch ($acl)
    {
        case 1 :
            echo "<tr class=td2><td nowrap class=td5 align=center>会员<td nowrap>" . $rs->f['id'] . "<td nowrap><a href='?op=agent&fp=member&cmd=edit&id=" . $rs->f['id'] . "&gametype={$gametype}'>" . $id . "</a><td nowrap>" . $rs->f['name'];
            echo "<td nowrap align=right>" . $rs->f['amount'];
            //if ($g_init_mode_6h && $reat0_open)
            //{
            //    echo "<td nowrap align=right>" . $rs->f['rate0'];
            //}
           // if ($g_init_mode_3d)
           // {
           //     echo "<td nowrap align=right>" . $rs->f['amount_3d'] . "<td nowrap align=right>" . $rs->f['amount_3s1'];
           // }
            echo "<td nowrap>" . ( $rs->f['lastlogdt'] == "" ? "" : date("Y-m-d", $rs->f['lastlogdt']) ) . "<td nowrap>" . $rs->f['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $rs->f['id'] . ");>";
            $u2 = get_user($rs->f['prev_id'], $gametype);
        case 2 :
            $u2 = isset($u2) ? $u2 : $rs->f;
            echo "<tr class=td2><td nowrap class=td5 align=center>代理商<td nowrap>" . $u2['id'] . "<td nowrap><a href='?op=genagent&fp=agent&cmd=edit&id=" . $u2['id'] . "&gametype={$gametype}'>" . $u2['account'] . "</a><td nowrap>" . $u2['name'];
            echo "<td nowrap align=right>" . $u2['amount'];
            //if ($g_init_mode_6h && $reat0_open)
            //{
            //    echo "<td nowrap align=right>" . $u2['rate0'];
            //}
            //if ($g_init_mode_3d)
            //{
            //    echo "<td nowrap align=right>" . $u2['amount_3d'] . "<td nowrap align=right>" . $u2['amount_3s1'];
            //}
            echo "<td nowrap>" . ( $u2['lastlogdt'] == "" ? "" : date("Y-m-d", $u2['lastlogdt']) ) . "<td nowrap>" . $u2['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $u2['id'] . ");>";
            $u3 = get_user($u2['prev_id'], $gametype);
        case 3 :
            $u3 = isset($u3) ? $u3 : $rs->f;
            echo "<tr class=td2><td nowrap class=td5 align=center>总代理<td nowrap>" . $u3['id'] . "<td nowrap><a href='?op=shareowner&fp=genagent&cmd=edit&id=" . $u3['id'] . "&gametype={$gametype}'>" . $u3['account'] . "</a><td nowrap>" . $u3['name'];
            echo "<td nowrap align=right>" . $u3['amount'];
            //if ($g_init_mode_6h && $reat0_open)
            //{
            //    echo "<td nowrap align=right>" . $u3['rate0'];
            //}
            //if ($g_init_mode_3d)
            //{
            //    echo "<td nowrap align=right>" . $u3['amount_3d'] . "<td nowrap align=right>" . $u3['amount_3s1'];
            //}
            echo "<td nowrap>" . ( $u3['lastlogdt'] == "" ? "" : date("Y-m-d", $u3['lastlogdt']) ) . "<td nowrap>" . $u3['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $u3['id'] . ");>";
            $u4 = get_user($u3['prev_id'], $gametype);
        case 4 :
            $u4 = isset($u4) ? $u4 : $rs->f;
            $u5 = get_user($u4['prev_id'], $gametype);
            echo "<tr class=td2><td nowrap class=td5 align=center>股东<td nowrap>" . $u4['id'] . "<td nowrap><a href='?op=subsidary&fp=shareowner&cmd=edit&id=" . $u4['id'] . "&gametype={$gametype}'>" . $u4['account'] . "</a><td nowrap>" . $u4['name'];
            echo "<td nowrap align=right>" . $u4['amount'];
            //if ($g_init_mode_6h && $reat0_open)
            //{
            //    echo "<td nowrap align=right>" . $u4['rate0'];
            //}
            //if ($g_init_mode_3d)
            //{
            //    echo "<td nowrap align=right>" . $u4['amount_3d'] . "<td nowrap align=right>" . $u4['amount_3s1'];
            //}
            echo "<td nowrap>" . ( $u4['lastlogdt'] == "" ? "" : date("Y-m-d", $u4['lastlogdt']) ) . "<td nowrap>" . $u4['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $u4['id'] . ");>";
            echo "<tr class=td2><td nowrap class=td5 align=center>大股东<td nowrap>" . $u5['id'] . "<td nowrap><a href='?op=admin&fp=subsidary&cmd=edit&id=" . $u5['id'] . "&gametype={$gametype}'>" . $u5['account'] . "</a><td nowrap>" . $u5['name'];
            echo "<td nowrap align=right>" . $u5['amount'];
            if ($g_init_mode_6h && $reat0_open)
            {
                echo "<td nowrap align=right>" . $u5['rate0'];
            }
            //echo "<td nowrap align=right>" . $u5['amount_3d'] . "<td nowrap align=right>" . $u5['amount_3s1'];
            echo "<td nowrap>" . ( $u5['lastlogdt'] == "" ? "" : date("Y-m-d", $u5['lastlogdt']) ) . "<td nowrap>" . $u5['lastlogip'] . "<td align=center nowrap><input type=button value=按此查询 onclick=javascript:password_link(" . $gametype . "," . $u5['id'] . ");>";
    }
    echo "</table>";
    if ($showPerFlag)
    {
        $uStrArr = array(
            "<tr class=td2><td nowrap class=td5 align=center>代理<td nowrap>" . $u2['id'] . "<td nowrap>" . $u2['account'] . "<td nowrap>" . $u2['name'],
            "<tr class=td2><td nowrap class=td5 align=center>总代理<td nowrap>" . $u3['id'] . "<td nowrap>" . $u3['account'] . "<td nowrap>" . $u3['name'],
            "<tr class=td2><td nowrap class=td5 align=center>股东<td nowrap>" . $u4['id'] . "<td nowrap>" . $u4['account'] . "<td nowrap>" . $u4['name'],
            "<tr class=td2><td nowrap class=td5 align=center>大股东<td nowrap>" . $u5['id'] . "<td nowrap>" . $u5['account'] . "<td nowrap>" . $u5['name'],
            "<tr class=td2><td nowrap class=td5 align=center>公司<td nowrap align=center>--<td nowrap align=center>--<td nowrap align=center>--"
        );
        echo "<br /><table border='1' cellpadding='3' cellspacing='0' width='800'>";
        echo ( "<tr class=td1><td colspan=" . ( count($g_gametype_3d) + 4 ) ) . " width=\"100%\" align=center>占 成 列 表";
        echo "<tr class=td0><td width=\"50\">管理层<td width=\"30\">ID<td width=\"50\">帐号<td width=\"50\">名称";
        if ($g_init_mode_6h && $g_menu_enabled[0])
        {
            echo "<td nowrap class=paper6h>六合彩";
            $mpercent = $u2['mpercent'];
            $percent2 = $u2['percent0'];
            $percent3 = min($u3['percent1'], $u4['mpercent'] - $mpercent - $percent2);
            $percent4 = min($u4['percent1'], $u5['mpercent'] - $mpercent - $percent2 - $percent3);
            $upercent = 100 - $mpercent - $percent2 - $percent3 - $percent4;
            $uStrArr[0] .= "<td nowrap align=right>" . $mpercent;
            $uStrArr[1] .= "<td nowrap align=right>" . $percent2;
            $uStrArr[2] .= "<td nowrap align=right>" . $percent3;
            $uStrArr[3] .= "<td nowrap align=right>" . $percent4;
            $uStrArr[4] .= "<td nowrap align=right>" . $upercent;
        }
        if ($g_init_mode_3d)
        {
            foreach ($g_gametype_3d as $i => $val)
            {
                if ($g_menu_enabled[$i] && $i==12)
                {
                    $tbl = $g_gametype_3d[$i]['en'];
                    $tblName = $g_gametype_3d[$i]['ch'];
                    echo "<td nowrap class=paper" . $tbl . ">快开彩占成设置";
                    $u2 = get_user($rs->f['prev_id'], $i);
                    $u3 = get_user($u2['prev_id'], $i);
                    $u4 = get_user($u3['prev_id'], $i);
                    $u5 = get_user($u4['prev_id'], $i);
                    $mpercent = $u2['mpercent'];
                    $percent2 = $u2['percent0'];
                    $percent3 = min($u3['percent1'], $u4['mpercent'] - $mpercent - $percent2);
                    $percent4 = min($u4['percent1'], $u5['mpercent'] - $mpercent - $percent2 - $percent3);
                    $upercent = 100 - $mpercent - $percent2 - $percent3 - $percent4;
                    $uStrArr[0] .= "<td nowrap align=right>" . $mpercent;
                    $uStrArr[1] .= "<td nowrap align=right>" . $percent2;
                    $uStrArr[2] .= "<td nowrap align=right>" . $percent3;
                    $uStrArr[3] .= "<td nowrap align=right>" . $percent4;
                    $uStrArr[4] .= "<td nowrap align=right>" . $upercent;
                }
            }
        }
        foreach ($uStrArr as $val)
        {
            echo $val;
        }
        echo "</table>";
    }
}
else
{
    echo "<font color=red><b>会员搜寻</b></font> (可搜寻层次为：会员?股东, 搜寻会员或代理帐号时，可显示管理层层占成)<br>";
    echo "<form action=\"op.php?op=admin&fp=findmember&gametype={$gametype}\" method=post onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
    echo "请输入会员帐号：<input name='id' size='20'>";
    echo "&#12288;<input type='submit' name='submit' value='确 定'>";
    echo "</form>";
}
?>